package com.buss.product.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.buss.core.dic.RecordStatus;
import com.buss.core.exception.ServiceException;
import com.buss.core.persistence.OrderBy;
import com.buss.core.persistence.Paginalbe;
import com.buss.core.persistence.ResultList;
import com.buss.product.dao.CatePropDao;
import com.buss.product.model.CateProp;
import com.buss.product.model.CateProp.PropEntryWay;
import com.buss.product.model.CateProp.PropSelectType;
import com.buss.product.service.CatePropService;

@Service
public class CatePropServiceImpl implements CatePropService {

	@Autowired
	private CatePropDao propDao;
	
	@Override
	public CateProp saveProp(CateProp prop) throws ServiceException {
		if(propDao.getRowCount(prop.getPropGroup().getCompanyId(), prop.getCode()) > 0){
			throw new ServiceException("属性编码已经存在，请重新设置!");
		}
		return propDao.saveProp(prop);
	}

	@Override
	public void editProp(CateProp prop) {
		propDao.editProp(prop);
	}

	@Override
	public void removeProp(Long[] ids) {
		propDao.removeProp(ids);
	}

	@Override
	public CateProp loadProp(Long id) {
		return propDao.loadProp(id);
	}

	@Override
	public CateProp loadProp(String companyId, String code) {
		return propDao.loadProp(companyId, code);
	}

	@Override
	public ResultList<CateProp> queryProp(Long groupId, String name,
			Boolean isSearch, RecordStatus status, OrderBy orderBy,
			Paginalbe page) {
		return propDao.queryProp(groupId, name, isSearch, status, orderBy, page);
	}

	@Override
	public ResultList<CateProp> queryProp(Long[] groupIds, RecordStatus status,
			PropSelectType selectType, PropEntryWay entryWay, OrderBy orderBy) {		
		return propDao.queryProp(groupIds, status, selectType, entryWay, orderBy);
	}

}
